package com.china.produce.controller;


/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2022/11/11
 */
public class ThreadLocalController {

    private static final InheritableThreadLocal<String> threadLocal = new InheritableThreadLocal<>();

    private static final ThreadLocal<String> threadLocals = new ThreadLocal<>();

    public static void main(String[] args) {
        threadLocal.set("666");
        threadLocals.set("888");
        new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("1" + threadLocal.get());
                System.out.println("2"  + threadLocals.get());
            }
        }, "a").start();

        threadLocal.remove();

        System.out.println("3" + threadLocals.get());
    }
}
